/**
 * hnjz.com Inc.
 * Copyright (c) 2004-2011 All Rights Reserved.
 */
package com.hnjz;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hnjz.common.security.CtxUtil;

/**
 * 主页控制器
 * 
 * @author wumi
 * @version $Id: IndexController.java, v 0.1 Dec 27, 2011 10:22:04 AM Administrator Exp $
 */
@Controller
public class IndexController {
    /**日志*/
    private static final Log log = LogFactory.getLog(IndexController.class);

    @Autowired
    private IndexManager     indexManager;

    @Value("#{settings['WHETHER_THE_JOB_RUN']}")
    private String           whetherToRun;                                  //作业是否执行 0执行1不执行

    /**
     * 展示主页，主要是查询出左侧的菜单
     * 
     * @param model {@link ModelMap}
     * @return
     */
    @RequestMapping(value = "/i.htm")
    public String i(ModelMap model) {
        JSONArray arr = indexManager.i();
        model.addAttribute("menu", arr.toString());
        model.addAttribute("name", CtxUtil.getCurUser().getName());

        if (log.isDebugEnabled()) {
            log.debug("当前登录用户为：" + CtxUtil.getCurUser().getName());
        }
        return "i";
    }

    /**
     * 展示主页，主要是查询出左侧的菜单
     * 
     * @param model {@link ModelMap}
     * @return
     */
    @RequestMapping(value = "/home.htm")
    public String toHome(ModelMap model) {
        model.addAttribute("whetherToRun", whetherToRun);
        return "home";
    }

}
